<?php
/**
 * Smarty plugin
 * @package Smarty
 * @subpackage plugins
 */

/**
 * Replace cached inserts with the actual results
 *
 * @param string $results
 * @return string
 */
function smarty_insert_pp_dc($params, &$smarty) {
	$content = '';
	
	//echo $smarty->get_vars_context('cart_total', 'count');
	
	if( $smarty->caching == 1 ) {
		if( $params['type'] == 'cart_total:count' ) {
			$content .= $smarty->_tpl_vars['CONTEXT']['cart_total']['count'];
			
		} elseif( $params['type'] == 'cart_total:price' ) {
			$content .= '$' . number_format($smarty->_tpl_vars['CONTEXT']['cart_total']['price'], 2);
			
		} else {
			$content .= $params['value'];
		}
	} else {
		if( $params['type'] == 'cart_total:count' ) {
			$content .= $params['value'];
			
		} elseif( $params['type'] == 'cart_total:price' ) {
			$content .= '$' . number_format($params['value'], 2);
			
		} else {
			$content .= $params['value'];
		}
	}
	
	return $content;
}
//
?>